package com.controller;


import com.model.AppVersionUpgrade;
import com.page.GenericPage;
import com.po.AdvertisementPO;
import com.po.AdvertisementUpdatePo;
import com.po.AppVersionUpgradeModifyPO;
import com.po.AppVersionUpgradePO;
import com.result.Result;
import com.service.AppVersionUpgradeService;
import com.vo.AdvertisementVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value="AppVersionUpgradeApi",tags={"AppVersion"})
@CrossOrigin
@RestController
@RequestMapping("/appversionupgrade")
public class AppVersionUpgradeController {

    @Autowired
    AppVersionUpgradeService appVersionUpgradeService;


    @ApiOperation(value = "保存", httpMethod = "POST", notes = "保存")
    @RequestMapping(value = "/save", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<AppVersionUpgrade> save(@RequestBody AppVersionUpgradePO appVersionUpgradePO) {
        return appVersionUpgradeService.save(appVersionUpgradePO);
    }

    @ApiOperation(value = "更新", httpMethod = "POST", notes = "更新")
    @RequestMapping(value = "/update", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result modify(@RequestBody AppVersionUpgradeModifyPO appVersionUpgradeModifyPO) {
        return appVersionUpgradeService.modifyById(appVersionUpgradeModifyPO);
    }

    @ApiOperation(value = "分页查询", httpMethod = "GET", notes = "分页查询")
    @RequestMapping(value = "/queryAll", method = RequestMethod.GET)
    public Result<GenericPage<AppVersionUpgrade>> queryAll(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                                                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        Result<GenericPage<AppVersionUpgrade>> pageResult = appVersionUpgradeService.queryAll(pageNo, pageSize);
        return pageResult;
    }

    @ApiOperation(value = "获取最新", httpMethod = "GET", notes = "获取最新")
    @RequestMapping(value = "/queryLast", method = RequestMethod.GET)
    public Result<AppVersionUpgrade> queryLast(@RequestParam("deviceId")Long deviceId) {

        return appVersionUpgradeService.queryLast(deviceId);
    }

//    @ApiOperation(value = "publish发布", httpMethod = "GET", notes = "publish发布")
//    @RequestMapping(value = "/publish", method = RequestMethod.GET)
//    public Result<Boolean> publish() {
//        return appVersionUpgradeService.publish();
//    }
}
